#include<cstdio>
#include"HashTable.cpp"
long long fileLen(FILE* f);

int main()
{
    struct hashTable ht;
    hashTable_ctor(&ht, hashFunction5);

    char element[20] = {};
    FILE* f; FILE* f_out;
    if (!(f = fopen("Salinger", "r")))
        abort();
    if (!(f_out = fopen("out.csv", "a")))
        abort();

    long long len = fileLen(f);

    while(ftell(f) < len - 1)
    {
        fscanf(f, "%s", element);
        hashTable_addElement(&ht, element);
    }

    for(int i = 0; i < 997; fprintf(f_out, "%d,", ht.table[i++]->length));
    fprintf(f_out, "\n");

    return 0;
}

long long fileLen(FILE* f)
{
    long long length = 0;
    char n = 0;
    while (n!= EOF)
    {
        n = fgetc(f);
        length++;
    }
    fseek(f, 0, SEEK_SET);
    return length;
}
